home *** CD-ROM | disk | FTP | other *** search
/ Cre@te Online 2000 December / Cre@teOnline CD05.iso / MacSoft / XML ConsoleMax.sea / XML ConsoleMax / Required / esc.jar / com / extensibility / esc / ReportTableModel.class (.txt) < prev    next >
Encoding:
Java Class File  |  2000-06-30  |  3.9 KB  |  152 lines

  1. package com.extensibility.esc;
  2.  
  3. import com.extensibility.app.UI;
  4. import java.io.File;
  5. import java.util.Enumeration;
  6. import javax.swing.Icon;
  7.  
  8. public class ReportTableModel extends ESCTableModel {
  9.    public static final int REPORT_VALIDES = 0;
  10.    public static final int REPORT_NONVALIDES = 1;
  11.    protected int type;
  12.    protected ESCDocument doc;
  13.    protected Icon icnSchema = UI.getIcon("schema_valid.gif");
  14.    protected Icon icnSchemaNew = UI.getIcon("schema_new.gif");
  15.    protected Icon icnSchemaDel = UI.getIcon("schemaDeleted.gif");
  16.    protected Icon icnXml = UI.getIcon("xi_icon_small_valid.gif");
  17.    protected Icon icnXmlNew = UI.getIcon("xi_icon_small_new.gif");
  18.  
  19.    public ReportTableModel(int var1, ESCDocument var2) {
  20.       this.type = var1;
  21.       this.doc = var2;
  22.       if (var1 == 0) {
  23.          this.initializeValid();
  24.       } else {
  25.          this.initializeNotValid();
  26.       }
  27.  
  28.    }
  29.  
  30.    protected void initHeaderAndType() {
  31.    }
  32.  
  33.    public void initializeValid() {
  34.       super.cNames = new String[3];
  35.       super.cNames[0] = "";
  36.       super.cNames[1] = UI.getString("esc.reportwindow.filetable.column.file");
  37.       super.cNames[2] = UI.getString("esc.reportwindow.filetable.column.path");
  38.       super.cTypes = new Class[3];
  39.       super.cTypes[0] = Class.forName("javax.swing.ImageIcon");
  40.       super.cTypes[1] = Class.forName("java.lang.String");
  41.       super.cTypes[2] = Class.forName("java.lang.String");
  42.       Enumeration var1 = this.doc.getFiles().elements();
  43.  
  44.       while(var1 != null && var1.hasMoreElements()) {
  45.          ESCDocument.ESCFile var2 = (ESCDocument.ESCFile)var1.nextElement();
  46.          if (var2.isValid() && ((File)var2).isFile() && ((File)var2).exists()) {
  47.             super.rows.addElement(new ReportData(var2));
  48.          }
  49.       }
  50.  
  51.    }
  52.  
  53.    public void initializeNotValid() {
  54.       super.cNames = new String[4];
  55.       super.cNames[0] = "";
  56.       super.cNames[1] = UI.getString("esc.reportwindow.filetable.column.file");
  57.       super.cNames[2] = UI.getString("esc.reportwindow.filetable.column.errors");
  58.       super.cNames[3] = UI.getString("esc.reportwindow.filetable.column.path");
  59.       super.cTypes = new Class[4];
  60.       super.cTypes[0] = Class.forName("javax.swing.ImageIcon");
  61.       super.cTypes[1] = Class.forName("java.lang.String");
  62.       super.cTypes[2] = Class.forName("java.lang.String");
  63.       super.cTypes[3] = Class.forName("java.lang.String");
  64.       Enumeration var1 = this.doc.getFiles().elements();
  65.  
  66.       while(var1 != null && var1.hasMoreElements()) {
  67.          ESCDocument.ESCFile var2 = (ESCDocument.ESCFile)var1.nextElement();
  68.          if (!var2.isVirgin() && !var2.isValid() && ((File)var2).isFile() && ((File)var2).exists()) {
  69.             super.rows.addElement(new ReportData(var2));
  70.          }
  71.       }
  72.  
  73.    }
  74.  
  75.    public int getColumnCount() {
  76.       return super.cNames.length;
  77.    }
  78.  
  79.    public String getColumnName(int var1) {
  80.       return super.cNames[var1];
  81.    }
  82.  
  83.    public Class getColumnClass(int var1) {
  84.       return super.cTypes[var1];
  85.    }
  86.  
  87.    public Object getValueAt(int var1, int var2) {
  88.       ReportData var3 = (ReportData)super.rows.elementAt(var1);
  89.       ESCDocument.ESCFile var4 = var3.getESCFile();
  90.  
  91.       try {
  92.          switch (var2) {
  93.             case 0:
  94.                if (!((File)var4).exists()) {
  95.                   Icon var14 = this.icnSchemaDel;
  96.                   return var14;
  97.                }
  98.  
  99.                if (((File)var4).isFile() && !var4.isVirgin()) {
  100.                   if (var4.isXMLFile()) {
  101.                      Icon var13 = this.icnXml;
  102.                      return var13;
  103.                   }
  104.  
  105.                   Icon var12 = this.icnSchema;
  106.                   return var12;
  107.                }
  108.  
  109.                if (((File)var4).isFile() && var4.isVirgin()) {
  110.                   if (var4.isXMLFile()) {
  111.                      Icon var11 = this.icnXmlNew;
  112.                      return var11;
  113.                   }
  114.  
  115.                   Icon var10 = this.icnSchemaNew;
  116.                   return var10;
  117.                }
  118.  
  119.                Object var9 = null;
  120.                return var9;
  121.             case 1:
  122.                String var5 = ((File)var4).getName();
  123.                return var5;
  124.             case 2:
  125.                String var6 = this.type == 0 ? ((File)var4).getAbsolutePath() : String.valueOf(var4.getErrors().size());
  126.                return var6;
  127.             case 3:
  128.                String var7 = ((File)var4).getAbsolutePath();
  129.                return var7;
  130.          }
  131.       } catch (SecurityException var8) {
  132.       }
  133.  
  134.       return null;
  135.    }
  136.  
  137.    protected int getRowForObject(Object var1) throws IllegalArgumentException {
  138.       for(int var2 = 0; var2 < super.rows.size(); ++var2) {
  139.          if ((ReportData)super.rows.elementAt(var2) == (ReportData)var1) {
  140.             return var2;
  141.          }
  142.       }
  143.  
  144.       return -1;
  145.    }
  146.  
  147.    ReportData getDataForRow(int var1) {
  148.       Object var2 = super.getObjectForRow(var1);
  149.       return var2 != null ? (ReportData)var2 : null;
  150.    }
  151. }
  152.